package qdu.guisockets.serverlet;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class ServerUI extends JFrame{
    private JPanel subp; 
	private JTextArea tf1,tf2;
	private JButton btn;
    private JScrollPane scrollPane;
    public ServerUI(){
        tf1 = new JTextArea();
        scrollPane = new JScrollPane(tf1);
        tf2 = new JTextArea();
        btn = new JButton("发送");        
        subp = new JPanel(new BorderLayout());
    }
    public void initUI(){
        this.setPreferredSize(new Dimension(800, 600));
        this.setTitle("服务器端");
        tf1.setEditable(false);
        
        tf1.setBackground(Color.ORANGE);
        tf2.setBackground(Color.YELLOW);
        subp.setPreferredSize(new Dimension(600,100));
        subp.add(tf2, BorderLayout.CENTER); subp.add(btn, BorderLayout.EAST);

        this.add(scrollPane, BorderLayout.CENTER);
        this.add(subp, BorderLayout.SOUTH);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.pack(); 
        this.setVisible(true);
        tf2.setEditable(false);
        btn.setEnabled(false);
    }
    public String getTf1Msg() {
		return tf1.getText();
	}
    public void appendTf1Msg(String str){
        tf1.append(str+'\n');
    }
}
